package com.anniljing.kotlionlearn.Basic.classes

fun main() {
    val person = Person("A", 20)
    println(person)
    println("姓名：${person.name},\n年龄：${person.age}")

    val personSet=ClassSet("B")
    personSet.age=20
    println("姓名：${personSet.name},\n年龄：${personSet.age}")

    val personGet=ClassGet("C",20)
    println("姓名：${personGet.name},\n年龄：${personGet.age},\n是否成年：${personGet.isAdult}")

}

class Person(val name: String, var age: Int)

class ClassSet(val name: String) {
    var age = 0
        set(value) {
            field = value
        }
}

class ClassGet(val name: String, var age: Int) {
    val isAdult get() = run { age > 18 }
}

open class InheritanceShape {
    open fun draw() {}
}

class Circle : InheritanceShape() {
    override fun draw() {
        println("画圆")
    }
}